package org.testfire.realm.model.entities.testfire;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: granum
 * Date: Sep 11, 2007
 * Time: 9:16:41 PM
 */
@Entity
@Table(catalog = "testfire", name = "testset_result")
public class TestsetResultEntity
{
	private Integer id;
	private Timestamp started;
	private Timestamp finished;
	private Integer statuscode;
	private List<TestResultsEntity> testResults;
	private TestsetEntity testset;
	private TestRunnerQueueEntity queue;
	private AgentEntity agent;
	private Integer failurecount;
	private Integer runtime;
	private String errormessage;

	@Basic
	@Column(name = "errormessage", length = 65535)
	public String getErrorMessage()
	{
		return errormessage;
	}

	public void setErrorMessage(String errormessage)
	{
		this.errormessage = errormessage;
	}

	@Basic
	@Column(name = "runtime", length = 10)
	public Integer getRunTime()
	{
		return runtime;
	}

	public void setRunTime(Integer runtime)
	{
		this.runtime = runtime;
	}

	@Basic
	@Column(name = "failurecount", length = 10)
	public Integer getFailureCount()
	{
		return failurecount;
	}

	public void setFailureCount(Integer failurecount)
	{
		this.failurecount = failurecount;
	}

	@ManyToOne(cascade = CascadeType.REFRESH )
	@JoinColumn(name = "agent_id", referencedColumnName = "id", nullable = false)
	public AgentEntity getAgent()
	{
		return agent;
	}

	public void setAgent(AgentEntity agent)
	{
		this.agent = agent;
	}

	@ManyToOne(cascade = CascadeType.REFRESH )
	@JoinColumn(name = "queue_id", referencedColumnName = "id", nullable = false)
	public TestRunnerQueueEntity getQueue()
	{
		return queue;
	}

	public void setQueue(TestRunnerQueueEntity queue)
	{
		this.queue = queue;
	}

	@ManyToOne(cascade = CascadeType.REFRESH )
	@JoinColumn(name = "testset_id", referencedColumnName = "id", nullable = false)
	public TestsetEntity getTestset()
	{
		return testset;
	}

	public void setTestset(TestsetEntity testset)
	{
		this.testset = testset;
	}

	@OneToMany(mappedBy = "testsetResult", cascade = CascadeType.REFRESH )
	public List<TestResultsEntity> getTestResults()
	{
		return testResults;
	}

	public void setTestResults(List<TestResultsEntity> testResults)
	{
		this.testResults = testResults;
	}
	

	@Basic
	@Column(name = "statuscode", nullable = false, length = 11)
	public Integer getStatuscode()
	{
		return statuscode;
	}

	public void setStatuscode(Integer statuscode)
	{
		this.statuscode = statuscode;
	}

	@Basic
	@Column(name = "finished", length = 19)
	public Timestamp getFinished()
	{
		return finished;
	}

	public void setFinished(Timestamp finished)
	{
		this.finished = finished;
	}

	@Basic
	@Column(name = "started", nullable = false, length = 19)
	public Timestamp getStarted()
	{
		return started;
	}

	public void setStarted(Timestamp started)
	{
		this.started = started;
	}


	@Id
	@Column(name = "id", nullable = false, length = 10)
	public Integer getId()
	{
		return id;
	}

	public void setId(Integer id)
	{
		this.id = id;
	}
}
